<?php

namespace app\admin\model;

use think\Model;


class ClothmakingStock extends Model
{





    // 表名
    protected $name = 'clothmaking_stock';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text'
    ];



    public function getStatusList()
    {
        return ['待审核' => __('待审核'), '已审核' => __('已审核'), '已取消' => __('已取消')];
    }

    public function getStockTypeList()
    {
        return ['produce' => __('生产'), 'return' => __('退货'), 'other' => __('其他')];
    }
    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function plan()
    {
        return $this->belongsTo('app\admin\model\clothmaking_plan\Index', 'plan_id', 'id');

    }

    public function product()
    {
        return $this->belongsTo('\app\admin\model\clothmaking_product\Index', 'product_id', 'id');
    }

    public function user()
    {
        return $this->belongsTo('\app\admin\model\Admin', 'user_id', 'id');
    }




}
